<?php
$this->breadcrumbs=array(
	'Customers'=>array('admin'),
	$model->firstName.' '.$model->lastName,
);

$this->menu=array(
/* 
//	array('label'=>'List Customer', 'url'=>array('index')),
//	array('label'=>'Create Customer', 'url'=>array('create')),	
//	array('label'=>'Delete Customer', 'url'=>'#', 'linkOptions'=>array('submit'=>array('delete','id'=>$model->id),'confirm'=>'Are you sure you want to delete this item?')),
//	array('label'=>'Manage Customer', 'url'=>array('admin')),
	array('label'=>'Attachment('.$model->attachmentCount.')','url'=>array('attachment/admin','customerId'=>$model->id)),
	array('label'=>'Loan('.$model->loanCount.')','url'=>array('loan/admin','customerId'=>$model->id)),
*/
	array('label'=>'Deals('.$model->dealCount.')','url'=>array('dealCustomer/admin','customerId'=>$model->id)),
	//array('label'=>'Property('.$model->propertyCount.')','url'=>array('property/admin','customerId'=>$model->id)),
	array('label'=>'Communication('.$model->communicationCount.')','url'=>array('communication/admin','customerId'=>$model->id)),
);

//if(Yii::app()->user->checkAccess('customerInfoAccess',array('customerId'=>$model->id))){
	$this->menu[]=array('label'=>'Update Customer', 'url'=>array('update', 'id'=>$model->id));
	$this->menu[]=array('label'=>'Create Related Customer', 'url'=>array('create', 'copyFrom'=>$model->id));
//}

$this->sideBar=array('application.widgets.customer.CustomerRelationPortlet'=>array(
	'customer'=>$model,
));
?>

<h1>View Customer - <?php echo $model->firstName.' '.$model->lastName; ?></h1>

<?php $this->widget('zii.widgets.CDetailView', array(
	'data'=>$model,
	'attributes'=>array(
		'fileReferenceNo',
		'consultant',
		'valueStar',
		'title',
		'firstName',
		'lastName',
		'otherName',
		array(
			'name'=>'gender',
			'value'=>DataUtil::getGender($model->gender),
		),
		'dateOfBirth',
		'contactPhone',
		'contactMobile',
		'contactFax',
		'email',
		'companyName',
		'postalAddress',
		'postalSuburb',
		'postalPostcode',
		'postalState',
		'postalCountry',
		'physicalAddress',
		'physicalSuburb',
		'physicalPostcode',
		'physicalState',
		'physicalCountry',
		'BankName',
		'BankAccountNumber',
		'note',
		array(
			'label'=>'Create User',
			'value'=>$model->createUser?$model->createUser->fullName:'',
		),
	),
)); ?>

<!-- Start of Google Map -->
<?php
if($model->physicalAddress):
$address=$model->physicalAddress.', '.$model->physicalSuburb.' '.$model->physicalState.' '.$model->physicalPostcode.' '.$model->physicalCountry;
$mapContent=<<<EOF
<div class="gmap_details">
<h3>{$model->firstName} {$model->lastName}</h3>
<p><span>{$model->physicalAddress}<br />{$model->physicalSuburb} {$model->physicalState} {$model->physicalPostcode} {$model->physicalCountry}</span></p>
</div>
EOF;
Yii::app()->google->map('customer_gmap',$address,array(),$mapContent);
endif; ?>
<!-- End of Google Map -->

<!-- Start of Address Change Log -->
<?php 
$addressLogs=$model->addressLogs;
if(!empty($addressLogs)){
	$editable=Yii::app()->user->checkAccess('customerInfoAccess',array('customerId'=>$model->id));
	?>
<div id="customer-address-change-log">
	<h4>Postal Address Change History</h4>
	<div>Current Postal Address: <?php echo $model->postalAddress; ?>
	<?php echo $model->postalSuburb; ?>
	<?php echo $model->postalPostcode; ?>
	<?php echo $model->postalState; ?>
	<?php echo $model->postalCountry;?></div>
	<?php foreach ($addressLogs as $addressLog) {
		?>
	<div class="customer-address-change-log-item">
		<div class="customer-address-change-log-item-meta">
			Changed On <?php echo $addressLog->changeDate; ?> By <?php echo $addressLog->changeUser->getFullName();?>.
			<?php if($editable){ ?>			
			<span class="customer-address-change-log-item-delete"><?php echo CHtml::link(CHtml::image(Yii::app()->baseUrl.'/images/icons/cross.png','Delete'),
			array('deleteAddressLog','addressLogId'=>$addressLog->id),array('confirm'=>'Delete this address change log?'));?></span>
			<?php } ?>
		</div>
		<div class="customer-address-change-log-item-address">
		<span class="customer-address-change-log-item-address-label">Old address:</span>
	<?php echo $addressLog->postalAddress; ?>
	<?php echo $addressLog->postalSuburb; ?>
	<?php echo $addressLog->postalPostcode; ?>
	<?php echo $addressLog->postalState; ?>
	<?php echo $addressLog->postalCountry;?>
		</div>
	</div>
		<?php
	}?>
</div>	
	<?php
}

?>